package com.kailu.hotel.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.kailu.hotel.model.RoomBookingModel;
import com.kailu.hotel.service.RoomBookingManager;
import com.kailu.hotel.service.RoomManager;

/**
 * @author viet.ch
 * @generated May 4, 2014
 * @from VN
 */

@Controller
public class RoomBookingController {

	@Autowired
	RoomBookingManager bookingManager;
	
	@Autowired
	RoomManager roomManager;
	
	@RequestMapping(value = "booking", method = RequestMethod.POST)
    public String addBooking(@ModelAttribute(value="book") RoomBookingModel book, BindingResult result, ModelMap map)
    {
		map.addAttribute("room",roomManager.getRoom(book.getRoom_id()));
		map.addAttribute("book",book);
		bookingManager.addBooking(book);
		return "room_list_3";
    }
	
    @RequestMapping(value = "/roomlist/{room_id}", method = RequestMethod.GET)
	public String getRoomList(@PathVariable("room_id") int room_id,ModelMap map) {
    	map.addAttribute("room",roomManager.getRoom(room_id));
		return "room_list_2";
	}
    
//    @RequestMapping(value = "/roomlist/{room_id}/success", method = RequestMethod.GET)
//    public String get(@PathVariable("room_id") int room_id,ModelMap map) {
//    	map.addAttribute("room",roomManager.getRoom(room_id));
//    	map.addAttribute("book",)
//		return "room_list_2";
//	}
	
}
